/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Design;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Windows.Forms;

namespace DaveSexton.DocProject.Sandcastle.BuildComponents.Editors
{
	internal sealed class DisplayLoadExceptionEditor : UITypeEditor
	{
		#region Public Properties
		public override bool IsDropDownResizable
		{
			get
			{
				return true;
			}
		}
		#endregion

		#region Private / Protected
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="DisplayLoadExceptionEditor" /> class.
		/// </summary>
		public DisplayLoadExceptionEditor()
		{
		}
		#endregion

		#region Methods
		public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.Modal;
		}

		public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
		{
			SandcastleBuildComponent component = (SandcastleBuildComponent) value;

			if (component != null)
			{
				using (SandcastleBuildComponentBasicEditorDialog dialog = new SandcastleBuildComponentBasicEditorDialog(component))
				{
					dialog.ShowDialog(DocProjectEnvironment.MainWindow);
				}
			}

			return value;
		}
		#endregion
	}
}
